import {Injectable} from '@angular/core';
import {_HttpClient} from '@delon/theme';
import {Observable} from 'rxjs/Observable';
import {UserShow} from './show/show.modle';

@Injectable()
export class UserService {

    url_userlist = 'User/list';

    url_showuserinfo = 'User/show';

    url_updateinfo = 'User/update';

    url_resetpwd = 'User/resetpwd';


    constructor(private http: _HttpClient) {
    }


    getuserlist(pageCurrent: number): Observable<{}> {
        return this.http.get<{}>(this.url_userlist, {page: pageCurrent});
    }

    showuser(id: number): Observable<UserShow> {
        return this.http.get<UserShow>(this.url_showuserinfo, {id: id});
    }

    resetpwd(id: number, pwd: string): Observable<string> {
        return this.http.post<string>(this.url_resetpwd, JSON.stringify({pwd: pwd, id: id}));
    }

    updateinfo(userinfo: UserShow): Observable<string> {
        return this.http.post<string>(this.url_updateinfo, JSON.stringify(userinfo));
    }
}
